package com.guigu.qingcheng.servicegoods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.guigu.qingcheng.pojo.goods.TbSku;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author testjava
 * @since 2020-07-08
 */
public interface TbSkuMapper extends BaseMapper<TbSku> {

    /**
     * 扣减库存方法
     * @param id
     * @param num
     */
    @Select("update tb_sku set num = num-#{num} where id=#{id}")
    public void deductionStock(@Param("id") String id, @Param("num")
            Integer num);

    /**
     * 添加销量
     * @param id
     * @param num
     */
    @Select("update tb_sku set sale_num = sale_num + #{num} where id=#{id}")
    public void addSaleNum(@Param("id") String id, @Param("num") Integer
            num);

}
